package com.recsmile.sgs.client.listener;

import java.util.Set;

import com.recsmile.sgs.client.card.Card;
import com.recsmile.sgs.client.commonds.sync.SyncOtherPlayerCardGameUIClientCommand;
import com.recsmile.sgs.client.commonds.sync.SyncPlayerCardGameUIClientCommand;
import com.recsmile.sgs.client.entity.CardOnHandListener;
import com.recsmile.sgs.client.entity.GameRoom;
import com.recsmile.sgs.client.util.SyncCommandsUtil;

public class ServerInGameCardOnHandListener extends ServerInGamePlayerListener implements CardOnHandListener {

	public ServerInGameCardOnHandListener(String name, Set<String> allNames, GameRoom room) {
		super(name, allNames, room);
	}
	@Override
	public void onCardAdded(Card card) {
		room.sendCommandToPlayers(
			SyncCommandsUtil.generateMapForDifferentCommand(
				name, 
				otherNames, 
				new SyncPlayerCardGameUIClientCommand(card, true), 
				new SyncOtherPlayerCardGameUIClientCommand(name, true, 1)
			)
		);
	}

	@Override
	public void onCardRemoved(Card card) {
		room.sendCommandToPlayers(
			SyncCommandsUtil.generateMapForDifferentCommand(
				name, 
				otherNames, 
				new SyncPlayerCardGameUIClientCommand(card, false), 
				new SyncOtherPlayerCardGameUIClientCommand(name, false, 1)
			)
		);	
	}

}